/***************************************************************************
 *
 * $Id: tig.h 2 2009-08-02 11:30:22Z Michael.McTernan $
 *
 * This file is part of tdgen, a timing diagram renderer.
 * Copyright (C) 2005 Michael C McTernan, Michael.McTernan.2001@cs.bris.ac.uk
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 **************************************************************************/

#ifndef TIG_H
#define TIG_H

/*****************************************************************************
 * Header Files
 *****************************************************************************/

#include <stdio.h>

/*****************************************************************************
 * Preprocessor Macros & Constants
 *****************************************************************************/

/*****************************************************************************
 * Typedefs
 *****************************************************************************/

typedef enum
{
    /* Global attributes */
    TIG_GATTR_DIVS,

    /* Per wave attributes */
    TIG_ATTR_COLOUR,
    TIG_ATTR_URL,

    NUM_TIG_ATTR
}
tig_attr_t;


typedef struct tig_attrlist
{
    tig_attr_t           attr;
    char                *val;

    struct tig_attrlist *next;
}
tig_attrlist_t;


typedef struct tig_wave
{
    char                *label;
    char                *pattern;

    struct tig_wave     *next;
    tig_attrlist_t      *attrList;
}
tig_wave_t;

typedef struct
{
    tig_wave_t          *waves;
    tig_attrlist_t      *gattr;
}
tig_t;

/*****************************************************************************
 * Global Variable Declarations
 *****************************************************************************/

/*****************************************************************************
 * Global Function Declarations
 *****************************************************************************/

tig_t          *TigParse(FILE *f);

tig_wave_t     *TigWaveAlloc(const char *label, const char *pattern);
tig_wave_t     *TigWaveLink(tig_wave_t *head, tig_wave_t *n);
tig_wave_t     *TigWaveLinkAttr(tig_wave_t *wave, tig_attrlist_t *attrl);
void            TigWaveDump(const tig_wave_t *wave);

tig_attrlist_t *TigAttrAlloc(tig_attr_t a, const char *val);
tig_attrlist_t *TigAttrLink(tig_attrlist_t *head, tig_attrlist_t *n);
void            TigAttrDump(const tig_attrlist_t *attr);


#endif /* TIG_H */
